﻿<?php
require 'UploadFile.class.php';//导入上传类

$upload = new UploadFile();//实例化
$upload->maxSize  = 3145728 ;//设置上传文件大小 
$upload->allowExts  = array('jpg', 'gif', 'png', 'jpeg');//设置上传文件类型
$upload->savePath =  './uploads/';//设置附件上传目录
$upload->thumb = true;//设置需要生成缩略图，仅对图像文件有效 
$upload->imageClassPath = 'Image.class.php'; // 设置引用图片类库包路径 
$upload->thumbPrefix = 'm_,s_';//设置需要生成缩略图的文件后缀 
$upload->thumbMaxWidth = '400,100'; //设置缩略图最大宽度 
$upload->thumbMaxHeight = '400,100'; //设置缩略图最大高度
$upload->saveRule = uniqid; //设置上传文件规则 
$upload->thumbRemoveOrigin = true; //删除原图 


if(!$upload->upload()) {
	echo $this->error($upload->getErrorMsg());//捕获上传异常 
}else{
	//取得成功上传的文件信息
	$info = $upload->getUploadFileInfo();
	
	echo '<img src="./uploads/m_'.$info[0]['savename'].'" width="300" height="300" /><br />';	
}

?>